package com.xbts.system.domain;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xbts.common.annotation.Excel;
import com.xbts.common.core.domain.BaseEntity;
import com.xbts.common.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Objects;

/**
 * 活动管理对象 party_active_manage
 *
 * @author xbts
 * @date 2023-06-12
 */
@Data
@ApiModel("活动管理对象")
@TableName("party_active_manage")
public class PartyActiveManage extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 活动编号
     */
    @TableId
    private String activityCode;

    /**
     * 活动名称
     */
    @Excel(name = "活动名称")
    @ApiModelProperty("活动名称")
    @NotEmpty(message = "活动名称不能为空")
    private String activityName;

    /**
     * 活动类别，枚举：activity_classification
     */
    @Excel(name = "活动类别，枚举：activity_classification")
    @ApiModelProperty("活动类别，枚举：activity_classification")
    @NotEmpty(message = "活动类别，枚举：activity_classification不能为空")
    private String activityClassification;

    /**
     * 活动描述
     */
    @Excel(name = "活动描述")
    @ApiModelProperty("活动描述")
    @Length(min = 1, max = 100, message = "活动描述长度为1-100位")
    private String activeDescribe;

    /**
     * 活动赠送积分
     */
    @Excel(name = "活动赠送积分")
    @ApiModelProperty("活动赠送积分")
    @NotNull(message = "活动赠送积分不能为空")
    private Double rewardPoints;

    public <T> QueryWrapper<T> queryWrapper() {
        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(activityCode)) {
            queryWrapper.like("activity_code", activityCode.trim());
        }
        if (StringUtils.isNotEmpty(activityName)) {
            queryWrapper.like("activity_name", activityName.trim());
        }
        queryWrapper.eq(StringUtils.isNotEmpty(activityClassification), "activity_classification", activityClassification);
//        queryWrapper.like(StringUtils.isNotEmpty(activeDescribe), "active_describe", activeDescribe);
//        queryWrapper.eq(!Objects.isNull(rewardPoints), "reward_points", rewardPoints);
        return queryWrapper;
    }
}